<?php
  session_start();					// 启用Session
  require 'db_connect.php';         // 连接数据库
  if ($_SESSION["username"]) {		// 判断是否处于成功登录状态
    header("Location: pannel.php");	// 跳转到面板页面
	exit();							// 终止后续代码的执行
  }
?>
<html>
  <head>
    <meta charset="utf-8"/>
    <title>账户登录</title>
	<link rel="stylesheet" href="css/style.css"/>
  </head>
  <body onload="body_onload_handler()">
    <div class="card-container">
      <form action="login.php" method="POST" id="login-form">
        <div id="login-title"><h3>身份认证</h3> </div>
        <div class="input-group" id="username">
          <input type="text" name="username" 
                 placeholder="学工号/手机号/邮箱" required>
        </div>
        <div class="input-group" id="password">
          <input type="password" name="password" 
                 placeholder="密码" required>
        </div>
        <div class="input-group" id="captcha-input">
          <input type="text" name="code" placeholder="请输入验证码">
        </div>
        <div class="input-group" id="captcha-img">
<?php
  $_SESSION["code"] = rand()%10;
?>  
          <img src="img/code_<?=$_SESSION["code"]?>.png">

        </div>
        <p id="captcha-info">验证码只包含字母,不区分大小写</p>
		<div class="alert" id="login-alert"></div>
        <div class="form-group">
		  <button class="button" id="login-submit" type="submit"><span>登录</span></button>
		</div>
      </form>
    </div>
  </body>
</html> 
